package cn.com.nwpu.visual_system.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;

/**
 * @author Hutengzhong
 * @version 1.0.0
 * @title Sensor
 * @description TODO 传感器类
 * @date 2024/4/27 21:34
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Sensor {
    private Integer sensorId;
    private String sensorName;
    private String sensorDetail;
    private String sensorType;
    private Integer inId;
    private Integer outId;
    private Double maxValue;
    private Double minValue;
    public Sensor(HashMap parameters){
        if (parameters == null){
            return;
        }else {
            if(parameters.containsKey("sensorId")){
                sensorId = Integer.parseInt((String)parameters.get("sensorId"));
            }
            if(parameters.containsKey("sensorName")){
                sensorName = (String)parameters.get("sensorName");
            }
            if(parameters.containsKey("sensorDetail")){
                sensorDetail = (String)parameters.get("sensorDetail");
            }
            if(parameters.containsKey("sensorType")){
                sensorType = (String)parameters.get("sensorType");
            }
            if(parameters.containsKey("inId")){
                inId = Integer.parseInt((String)parameters.get("inId"));
            }
            if(parameters.containsKey("outId")){
                outId = Integer.parseInt((String)parameters.get("outId"));
            }
            if(parameters.containsKey("maxValue")){
                maxValue = Double.parseDouble((String)parameters.get("maxValue"));
            }
            if(parameters.containsKey("minValue")){
                minValue = Double.parseDouble((String)parameters.get("minValue"));
            }
        }
    }
}
